﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Diagnostics;

namespace MyCalendar.Utils
{
    public class DateTimeManager : INotifyPropertyChanged
    {

        private DateTime mDateTime;

        public event PropertyChangedEventHandler PropertyChanged;

        public void OnPropertyChanged (string pName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged (this, new PropertyChangedEventArgs (pName));
            }
        }

        public DateTimeManager ()
        {
        }

        public DateTimeManager (DateTime pDateTime)
        {
            SetDateTime (pDateTime);
        }

        public void SetDateTime (DateTime pDateTime)
        {
            mDateTime = pDateTime;
            Year = pDateTime.Year;
            Month = pDateTime.Month.ToString();
            Day = pDateTime.Day;
        }


        private int mYear;

        public DateTime Today
        {
            get
            {
                return mDateTime;
            }
            set
            {
                mDateTime = value;
            }
        }

        public int Year
        {
            get
            {
                return mYear;
            }
            set
            {
                mYear = value;
                OnPropertyChanged ("Year");
 
            }
        }


        private int mMonth; 

        public String Month
        {
            get
            {
                switch (mMonth)
                {
                    case 1:
                        return "一月";
                    case 2:
                        return "二月";
                    case 3:
                        return "三月";
                    case 4:
                        return "四月";
                    case 5:
                        return "五月";
                    case 6:
                        return "六月";
                    case 7:
                        return "七月";
                    case 8:
                        return "八月";
                    case 9:
                        return "九月";
                    case 10:
                        return "十月";
                    case 11:
                        return "十一月";
                    case 12:
                        return "十二月";

                    default:
                        return "一月";

                }
            }
            set
            {
                try
                {
                    mMonth = int.Parse (value);
                    OnPropertyChanged ("Month");
                }
                catch (Exception e)
                {
                    Debug.WriteLine (e.Message);
                }

            }
        }

        public int Day
        {
            get;
            set;
        }

        public int Week
        {
            get;
            set;
        }
    }
}
